<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8" />
<title>{$WEB_EXT_CFG.PAGE_TITLE} v0.1a</title>
<include file="Public:scripts"/>
<script type="text/javascript">
$(document).ready(function(){
	
	/* setup navigation, content boxes, etc... */
	Administry.setup();
	
	// 固定浮动条 //////////////////////////////////////
	(function () {
		var el= $('#pagetitle');
		var ec= $('#page');
		var w = el.next().width();
		var c = ec.offset().top;
		el.css({'top':c, 'width':w});
		$(window).scroll(function () {
			var e = document.body.scrollTop || document.documentElement.scrollTop;
			if (e <= 0) {
				el.css({'top':c.toString()+'px'});
			} else {
				if (e <= c) {
					el.css({'top':(c-e).toString()+'px'});
				} else {
					el.css({'top':0});
				};
			};
		});
	})();
	$(window).trigger('scroll');
	
	$('#cascade_option').click(function () {
		var cls = $('#cascade_content').css('display') == 'none' ? 'block' : 'none';
		$('#cascade_content').css({"display":cls});
	});
	
	// init select
	var l1 = (new Function('return '+$('#level1').val()))();
	var l2 = (new Function('return '+$('#level2').val()))();
	var l3 = (new Function('return '+$('#level3').val()))();
	var l1_html = '<option value="-1">请选择...</option>';
	for(var i=0; i<l1.length; i++) {
		l1_html += '<option value="'+l1[i]['id']+'">'+l1[i]['name']+'</option>';
	};
	$('#select1').html(l1_html).change(function () {
		var parent = $(this).val();
		var l2_html = '<option value="-1">请选择...</option>';
		for(var i=0; i<l2.length; i++) {
			if (l2[i]['parent'] != parent) continue;
			l2_html += '<option value="'+l2[i]['id']+'">'+l2[i]['name']+'</option>';
		};
		$('#select2').html(l2_html).change(function () {
			var parent = $(this).val();
			var l3_html = '<option value="-1">请选择...</option>';
			for(var i=0; i<l3.length; i++) {
				if (l3[i]['parent'] != parent) continue;
				l3_html += '<option value="'+l3[i]['id']+'">'+l3[i]['name']+'</option>';
			};
			$('#select3').html(l3_html);
		});
	});

	if ($('#_select1').length == 1) $('#select1').val($('#_select1').val()).trigger('change');
	if ($('#_select2').length == 1) $('#select2').val($('#_select2').val()).trigger('change');
	if ($('#_select3').length == 1) $('#select3').val($('#_select3').val());

});
</script>
</head>
<body>
	<!-- Header -->
	<header id="top">
		<div class="wrapper">
			<!-- Title/Logo - can use text instead of image -->
			<include file="Public:title"/>
			<!-- Top navigation -->
			<div id="topnav">
				<a href="#"><img class="avatar" src="/public/demo/img/user_32.png" alt="" /></a>
				登录为 <b>{$session_admin_name}</b>
				<span>|</span> <a href="/dashboard/settings">设置</a>
				<span>|</span> <a href="/index/signout">退出</a><br />
				<small>您有 <a href="/dashboard/message?unread" class="high"><b>1</b> 新消息!</a></small>
			</div>
			<!-- End of Top navigation -->
			<!-- Main navigation -->
			<include file="Public:menu"/>
			<!-- End of Main navigation -->
			<!-- Aside links -->
			<!-- aside><b>English</b> &middot; <a href="#">Spanish</a> &middot; <a href="#">German</a></aside -->
			<!-- End of Aside links -->
		</div>
	</header>
	<!-- End of Header -->
	<!-- Page title -->
	<div id="pagetitle" style="position:fixed;z-index:20;">
		<div class="wrapper">
			<h1>渠道&nbsp;&nbsp;&bull;&nbsp;&nbsp;管理全部渠道/代理/经销/专营</h1>
		</div>
	</div>
	<!-- End of Page title -->
	
	<!-- Page content -->
	<div id="page">
		<!-- Wrapper -->
		<div class="wrapper" style="margin-top:52px;">
				<!-- Left column/section -->
				<section class="column width6 first">
					
					<h4>渠道清单:&nbsp;&nbsp;<a href="#">{$count}家</a></h4>
					
					<table id="report" class="stylized full" style="">
						<thead>
							<tr>
								<th>名称</th>
								<th>地区</th>
								<th>类别</th>
								<th>联系人</th>
								<th class="ta-right">创建时间</th>
								<th class="ta-right">操作</th>
							</tr>
						</thead>
						<tbody>
							<volist name="list" id="item">
							<tr>
								<td class="title"><a href="#"><b>{$item.enterprise}</b></a></td>
								<td>{$item.province},{$item.city},{$item.district}</td>
								<td>{$item.type}</td>
								<td>{$item.contact_name}</td>
								<td class="ta-right">{$item.create_time}</td>
								<td class="ta-right"><a href="?id={$item.id}#f1">修改</a>&nbsp;|&nbsp;<a href="#">删除</a></td>
							</tr>
							<tr>
								<td class="ta-right" colspan="6">
								<a href="/agent/user?agent_id={$item.id}">添加管理员</a>&nbsp;|&nbsp;<a href="/shop/quick?agent_id={$item.id}">一键开店</a>&nbsp;|&nbsp;<a href="#">LBS设置</a></td>
							</tr>
							</volist>
						</tbody>
						<tfoot>
							<tr>
								<td colspan="6" class="ta-right">{$page}</td>
							</tr>
						</tfoot>
					</table>
					<a name="f1"></a>
					<form id="agentForm" name="agentForm" method="post" action="/agent/save">
					<input type="hidden" name="id" id="id" value="{$info.id}"/>
						<fieldset>
							<legend id="cascade_option">渠道设置</legend>
							<div id="cascade_content">
							<p>
								<label class="required" for="enterprise">企业全称:</label><br/>
								<input type="text" id="enterprise" class="half" value="{$info.enterprise}" name="enterprise"/>
							</p>
							
							<p>
								<label class="required" for="addr">详细地址:</label><br/>
								<select id="select1" class="sma" name="select1"></select>
								<select id="select2" class="sma" name="select2"></select>
								<select id="select3" class="sma" name="select3"></select><br/>
								<input type="text" id="addr" class="half" value="{$info.addr}" name="addr"/>
								<if condition="$info.province neq 0"><input type="hidden" name="_select1" id="_select1" value="{$info.province}"></if>
								<if condition="$info.city neq 0"><input type="hidden" name="_select2" id="_select2" value="{$info.city}"></if>
								<if condition="$info.district neq 0"><input type="hidden" name="_select3" id="_select3" value="{$info.district}"></if>
							</p>
							
							<p>
								<label for="post">邮政编码:</label><br/>
								<input type="text" id="post" class="sma" value="{$info.post}" name="post"/>
							</p>

							<p>
								<label class="required" for="tel">电话(请填写区号):</label><br/>
								<input type="text" id="tel" class="qtr" value="{$info.tel}" name="tel"/>
							</p>

							<p>
								<label class="required" for="fax">传真(请填写区号):</label><br/>
								<input type="text" id="fax" class="qtr" value="{$info.fax}" name="fax"/>
							</p>
							
							<p>
								<label class="required" for="type">代理类别:</label><br/>
								<volist name="agent_type" id="item" index="key">
								<label class="choice" for="type{$key}"><input type="radio" id="type{$key}" value="{$key}" name="type" <if condition="$info.type eq $key">checked="checked"</if>/>{$item}</label><br/>
								</volist>
							</p>

							<p>
								<label class="required" for="contact_name">联系人:</label><br/>
								<input type="text" id="contact_name" class="qtr" value="{$info.contact_name}" name="contact_name"/>
								<label class="choice" for="contact_gender1"><input type="radio" id="contact_gender1" value="1" name="contact_gender" <if condition="$info.contact_gender eq 1">checked="checked"</if>/>先生</label>
								<label class="choice" for="contact_gender2"><input type="radio" id="contact_gender2" value="2" name="contact_gender" <if condition="$info.contact_gender eq 2">checked="checked"</if>/>女士</label>
							</p>

							<p>
								<label for="contact_title">联系人职务:</label><br/>
								<input type="text" id="contact_title" class="qtr" value="{$info.contact_title}" name="contact_title"/>
							</p>

							<p>
								<label class="required" for="contact_mobile">联系人手机:</label><br/>
								<input type="text" id="contact_mobile" class="qtr" value="{$info.contact_mobile}" name="contact_mobile"/>
							</p>

							<p>
								<label for="comment">备注:</label><br/>
								<textarea id="comment" class="half" name="comment" rows="6">{$info.comment}</textarea>
							</p>
							
							<p class="box"><input type="submit" class="btn btn-green big" value="保存设置"/> &nbsp; <input type="reset" class="btn" value="重置"/></p>
							</div>
						</fieldset>

					</form>
				
					<div class="clear">&nbsp;</div>
				
				</section>
				<!-- End of Left column/section -->
				
				<!-- Right column/section -->
				<aside class="column width2">
					<div id="rightmenu">
						<header>
							<h3>账户信息</h3>
						</header>
						<dl class="first">
							<dt><img width="16" height="16" alt="" src="/public/demo/img/key.png"></dt>
							<dd><a href="#">企业账户 (admin)</a></dd>
							<dd class="last">30d体验版.</dd>
							
							<dt><img width="16" height="16" alt="" src="/public/demo/img/help.png"></dt>
							<dd><a href="#">技术支持</a></dd>
							<dd class="last">相关技术支持请查看 http://doc.f-fusion.com</dd>
						</dl>
					</div>
				</aside>
				<!-- End of Right column/section -->
				
		</div>
		<!-- End of Wrapper -->
	</div>
	<!-- End of Page content -->
	
	<!-- Page footer -->
	<include file="Public:footer"/>
	<!-- End of Page footer -->
	
	<!-- Animated footer -->
	<include file="Public:footer-float"/>
	<!-- End of Animated footer -->
	
	<!-- Scroll to top link -->
	<include file="Public:go"/>
<div style="display:none;">
<textarea name="level1" id="level1">{$level1}</textarea>
<textarea name="level2" id="level2">{$level2}</textarea>
<textarea name="level3" id="level3">{$level3}</textarea></div>
</body>
</html>